import { routes } from '@/router/index'
import type { RouteRecordRaw } from 'vue-router'



const menu = [...routes]
menu.unshift({
    path: '/home',
    name: '首页',
    meta: {
        sort: 0,
        icon: 'icon-home'
    },
    component: () => import('@/views/Home/index.vue')

})

function handleMenu(routes: RouteRecordRaw[]) {
    const sortArr = (routes || []).sort((a, b) => (a.meta?.sort as number) - (b.meta?.sort as number))
    sortArr.forEach((item) => {
        if (item.children) {
            handleMenu(item.children)
        }
    })
}

handleMenu(menu)



export default menu
